const express = require('express');
const router = express.Router();
const authController = require('../controllers/authController');
const { auth } = require('../middlewares/auth');
const { validate, userValidation } = require('../utils/validator');

// POST /api/auth/register - 用户注册
router.post('/register', validate(userValidation.register), authController.register);

// POST /api/auth/login - 用户登录
router.post('/login', validate(userValidation.login), authController.login);

// GET /api/auth/profile - 获取当前用户信息 (需要认证)
router.get('/profile', auth, authController.getCurrentUser);

// POST /api/auth/change-password - 修改密码 (需要认证)
router.post(
  '/change-password', 
  [auth, validate(userValidation.changePassword)], 
  authController.changePassword
);

// 验证码接口
router.get('/captcha', authController.generateCaptcha);

module.exports = router; 